<template>
    <div class="xl-table">
        <xlUntil text="创业活动" :queryParam="queryParam"  @addForm="addForm" @delBatch="delBatch" :add-btn="true" :untilVisible="false" :import-btn="false" @searchKeyWord="searchKeyWord" :searchColumns="columns"></xlUntil>
        <div class="xl-table-content">
            <xlTable
                    :columns="columns"
                    :dataSource="data"
                    rowKey="id"
                    :pagination="pagination"
                    :loading="loading"
                    @change="handleTableChange"
                    bordered
                    :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}">
                >
                <template v-slot:action="scope">
                    <a @click="editForm(scope.record)">编辑</a>
                    <a-divider type="vertical"/>
                    <a-dropdown>
                        <a class="ant-dropdown-link">更多 <a-icon type="down"/></a>
                        <a-menu slot="overlay">
                            <a-menu-item @click="seeForm(scope.record)">
                                <a>查看</a>
                            </a-menu-item>
                            <a-menu-item>
                                <a-popconfirm title="确定删除吗?" @confirm="() => delForm(scope.record.id)">
                                    <a>删除</a>
                                </a-popconfirm>
                            </a-menu-item>
                        </a-menu>
                    </a-dropdown>
                </template>

                <template v-slot:download="scope">
                    <a :href="scope.record.materialPath" target="_blank" v-if="scope.record.materialPath">查看文件</a>
                    <span v-else>暂无文件</span>
                </template>
            </xlTable>
        </div>
        <xlForm ref="xlForm" @handleOk="handleOk"></xlForm>
        <seeForm :column="2" ref="seeForm"></seeForm>
        <activityForm ref="activityForm" @handleOk="handleOk"></activityForm>
    </div>
</template>

<script>

    import xlMixin from '../../../../components/mixin'
    import activityForm from './model/form'
    export default {
        name: "index",
        mixins:[xlMixin],
        data(){
            return{
                columns:[
                    {
                        title: '序号',
                        key: 'rowIndex',
                        align: "center",
                        fixed: 'left',
                        width:'100px',
                        sorter: (a) => a.id,//排序
                        customRender: function (t, r, index) {
                            return parseInt(index) + 1;
                        }
                    },
                    {
                        title: '载体名称',
                        fixed: 'left',
                        dataIndex: 'carrierName',
                        type:'input'
                    },
                    {
                        title: '活动名称',
                        dataIndex: 'activityName',
                        type:'input'
                    },
                    {
                        title: '是否有附件',//排序
                        formVisible:false,
                        scopedSlots: {customRender: 'download'}
                    },
                    {
                        title: '活动日期',
                        dataIndex: 'activityDate',
                        type:'date'
                    },
                    {
                        title: '活动类型',
                        dataIndex: 'activityType',
                        type:'input',
                        required:false
                    },
                    {
                        title: '参加人数',
                        dataIndex: 'paticipateNum',
                        type:'input.number',
                        required:false
                    },
                    {
                        title: '活动日程描述',
                        dataIndex: 'durationTime',
                        type:'textarea',
                        span:2
                    },
                    {
                        title: '附件',
                        dataIndex: 'materialPath',
                        type:'upload.file',
                        tableVisible:true,
                        required:false,
                        fileTitle:{
                            titleVisible:true,
                            title:"活动内容及相关现场照片"
                        },
                        span:2
                    },
                    {
                        title: '操作',
                        dataIndex: 'action',
                        align: "center",
                        fixed: 'right',
                        width:'150px',
                        scopedSlots: {customRender: 'action'},
                    }
                ],
                url: {
                    list: "/system/api/carrierActivity/pageList",
                    add: '/system/api/carrierActivity/add',
                    edit: '/system/api/carrierActivity/update',
                    delete: "/system/api/carrierActivity/remove",
                    deleteBatch: "/system/api/carrierActivity/remove",
                    exportXlsUrl: "/system/api/carrierActivity/exportExcel",
                    importExcelUrl: "/system/api/carrierActivity/importExcel",
                    importExcelDemoUrl: "/system/api/carrierActivity/importTemplate"
                }
            }
        },
        components: {
            activityForm

        },
        created(){
            this.formatMerge()
            this.pageOnload()
        },
        methods:{
            addForm() {
                this.$refs.activityForm.tableTitle = '新增'
                // this.$refs.activityForm.formatData(this.columns)
                this.$refs.activityForm.visible = true
                this.$refs.activityForm.confirmLoading = false
                this.$refs.activityForm.formatForm({})
                this.$refs.activityForm.type = 1
            }
        }
    }
</script>

<style scoped lang="less">
    .xl-table{
        .xl-table-content{
            padding: 16px;
        }
    }
</style>
